package org.dromara.northstar.support.utils;

import static org.assertj.core.api.Assertions.assertThat;

import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.time.LocalTime;

import org.junit.jupiter.api.Test;

class ExceptionLogCheckerTest {
	
	String demoLogHasException = "2023-05-05 22:00:05.011  INFO 28008 --- [http-nio-80-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'\r\n"
			+ "2023-05-05 22:00:05.012  INFO 28008 --- [http-nio-80-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 1 ms\r\n"
			+ "2023-05-05 22:00:05.052  WARN 28008 --- [http-nio-80-exec-1] o.d.n.w.i.AuthorizationInterceptor       : token校验失败，IP：127.0.0.1\r\n"
			+ "2023-05-05 22:00:07.728  INFO 28008 --- [nioEventLoopGroup-3-2] o.d.northstar.event.BroadcastHandler     : 【客户端连接】-[42aea4f9-bd0d-411e-a160-f972abed913f],建立连接\r\n"
			+ "2023-05-05 22:02:07.275  INFO 28008 --- [nioEventLoopGroup-3-2] o.d.northstar.event.BroadcastHandler     : 【客户端断开】-[42aea4f9-bd0d-411e-a160-f972abed913f],断开连接\r\n"
			+ "2023-05-05 22:02:07.699  INFO 28008 --- [nioEventLoopGroup-3-4] o.d.northstar.event.BroadcastHandler     : 【客户端连接】-[7d9e854d-6044-449a-981d-70e993a012fc],建立连接\r\n"
			+ "2023-05-05 22:02:54.271  INFO 28008 --- [nioEventLoopGroup-3-4] o.d.northstar.event.BroadcastHandler     : 【客户端断开】-[7d9e854d-6044-449a-981d-70e993a012fc],断开连接\r\n"
			+ "2023-05-05 22:02:54.715  INFO 28008 --- [nioEventLoopGroup-3-6] o.d.northstar.event.BroadcastHandler     : 【客户端连接】-[dc2d5b00-53f5-4966-874f-3536531630d9],建立连接\r\n"
			+ "2023-05-05 22:03:03.096 ERROR 28008 --- [http-nio-80-exec-1] o.d.n.w.r.common.CommonControllerAdvice  : 找不到网关：undefined\r\n"
			+ "\r\n"
			+ "org.dromara.northstar.common.exception.NoSuchElementException: 找不到网关：undefined\r\n"
			+ "	at org.dromara.northstar.data.jdbc.GatewayRepoAdapter.lambda$0(GatewayRepoAdapter.java:51)\r\n"
			+ "	at java.base/java.util.Optional.orElseThrow(Optional.java:403)\r\n"
			+ "	at org.dromara.northstar.data.jdbc.GatewayRepoAdapter.findById(GatewayRepoAdapter.java:51)\r\n"
			+ "	at org.dromara.northstar.web.restful.ContractController.subscribedContracts(ContractController.java:56)\r\n"
			+ "	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n"
			+ "	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)\r\n"
			+ "	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n"
			+ "	at java.base/java.lang.reflect.Method.invoke(Method.java:568)\r\n"
			+ "	at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)\r\n"
			+ "	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150)\r\n"
			+ "	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117)\r\n"
			+ "	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)\r\n"
			+ "	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)\r\n"
			+ "	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)\r\n"
			+ "	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1071)\r\n"
			+ "	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:964)\r\n"
			+ "	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)\r\n"
			+ "	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)\r\n"
			+ "	at javax.servlet.http.HttpServlet.service(HttpServlet.java:670)\r\n"
			+ "	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)\r\n"
			+ "	at javax.servlet.http.HttpServlet.service(HttpServlet.java:779)\r\n"
			+ "	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)\r\n"
			+ "	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)\r\n"
			+ "	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)\r\n"
			+ "	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)\r\n"
			+ "	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)\r\n"
			+ "	at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:91)\r\n"
			+ "	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)\r\n"
			+ "	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)\r\n"
			+ "	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)\r\n"
			+ "	at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)\r\n"
			+ "	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)\r\n"
			+ "	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)\r\n"
			+ "	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)\r\n"
			+ "	at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)\r\n"
			+ "	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)\r\n"
			+ "	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)\r\n"
			+ "	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)\r\n"
			+ "	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)\r\n"
			+ "	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)\r\n"
			+ "	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)\r\n"
			+ "	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)\r\n"
			+ "	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:177)\r\n"
			+ "	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)\r\n"
			+ "	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)\r\n"
			+ "	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)\r\n"
			+ "	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)\r\n"
			+ "	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)\r\n"
			+ "	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)\r\n"
			+ "	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)\r\n"
			+ "	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)\r\n"
			+ "	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:891)\r\n"
			+ "	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1784)\r\n"
			+ "	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)\r\n"
			+ "	at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)\r\n"
			+ "	at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)\r\n"
			+ "	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)\r\n"
			+ "	at java.base/java.lang.Thread.run(Thread.java:833)\r\n"
			+ "\r\n"
			+ "2023-05-05 22:03:37.250  INFO 28008 --- [nioEventLoopGroup-3-6] o.d.northstar.event.BroadcastHandler     : 【客户端断开】-[dc2d5b00-53f5-4966-874f-3536531630d9],断开连接\r\n"
			+ "2023-05-05 22:03:37.646  INFO 28008 --- [nioEventLoopGroup-3-8] o.d.northstar.event.BroadcastHandler     : 【客户端连接】-[4a21ada2-8f3f-45ba-869f-69d4d10c0425],建立连接\r\n"
			+ "2023-05-05 22:05:40.060  INFO 28008 --- [nioEventLoopGroup-3-8] o.d.northstar.event.BroadcastHandler     : 【客户端断开】-[4a21ada2-8f3f-45ba-869f-69d4d10c0425],断开连接\r\n"
			+ "";
	
	String demoLogHasNoException = "2023-05-06 07:43:06.848  INFO 20980 --- [main] o.s.t.c.transaction.TransactionContext   : Began transaction (1) for test context [DefaultTestContext@352ff4da testClass = MarketDataRepositoryTest, testInstance = org.dromara.northstar.data.jdbc.MarketDataRepositoryTest@326dbe25, testMethod = testDeleteByExpiredAtBefore@MarketDataRepositoryTest, testException = [null], mergedContextConfiguration = [MergedContextConfiguration@3224a577 testClass = MarketDataRepositoryTest, locations = '{}', classes = '{class org.dromara.northstar.NorthstarApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTestContextBootstrapper=true}', contextCustomizers = set[[ImportsContextCustomizer@2e32ccc5 key = [org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration, org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration, org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration, org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration, org.springframework.boot.autoconfigure.sql.init.SqlInitializationAutoConfiguration, org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration, org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration, org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManagerAutoConfiguration]], org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@1a6d8329, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@71ba6d4e, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.autoconfigure.OverrideAutoConfigurationContextCustomizerFactory$DisableAutoConfigurationContextCustomizer@2e8c1c9b, org.springframework.boot.test.autoconfigure.actuate.metrics.MetricsExportContextCustomizerFactory$DisableMetricExportContextCustomizer@78e4deb0, org.springframework.boot.test.autoconfigure.filter.TypeExcludeFiltersContextCustomizer@351584c0, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@ac34dcb1, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@28261e8e, org.springframework.boot.test.context.SpringBootTestArgs@1, org.springframework.boot.test.context.SpringBootTestWebEnvironment@0], contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.event.ApplicationEventsTestExecutionListener.recordApplicationEvents' -> false]]; transaction manager [org.springframework.orm.jpa.JpaTransactionManager@64ef2719]; rollback [true]\r\n"
			+ "2023-05-06 07:43:06.874  INFO 20980 --- [main] o.s.t.c.transaction.TransactionContext   : Rolled back transaction for test: [DefaultTestContext@352ff4da testClass = MarketDataRepositoryTest, testInstance = org.dromara.northstar.data.jdbc.MarketDataRepositoryTest@326dbe25, testMethod = testDeleteByExpiredAtBefore@MarketDataRepositoryTest, testException = java.util.NoSuchElementException, mergedContextConfiguration = [MergedContextConfiguration@3224a577 testClass = MarketDataRepositoryTest, locations = '{}', classes = '{class org.dromara.northstar.NorthstarApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTestContextBootstrapper=true}', contextCustomizers = set[[ImportsContextCustomizer@2e32ccc5 key = [org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration, org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration, org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration, org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration, org.springframework.boot.autoconfigure.sql.init.SqlInitializationAutoConfiguration, org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration, org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration, org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManagerAutoConfiguration]], org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@1a6d8329, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@71ba6d4e, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.autoconfigure.OverrideAutoConfigurationContextCustomizerFactory$DisableAutoConfigurationContextCustomizer@2e8c1c9b, org.springframework.boot.test.autoconfigure.actuate.metrics.MetricsExportContextCustomizerFactory$DisableMetricExportContextCustomizer@78e4deb0, org.springframework.boot.test.autoconfigure.filter.TypeExcludeFiltersContextCustomizer@351584c0, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@ac34dcb1, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@28261e8e, org.springframework.boot.test.context.SpringBootTestArgs@1, org.springframework.boot.test.context.SpringBootTestWebEnvironment@0], contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.event.ApplicationEventsTestExecutionListener.recordApplicationEvents' -> false]]\r\n"
			+ "2023-05-06 07:43:06.889  INFO 20980 --- [SpringApplicationShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'\r\n"
			+ "2023-05-06 07:43:36.811  WARN 26408 --- [main] ory$DuplicateJsonObjectContextCustomizer : \r\n"
			+ "\r\n"
			+ "Found multiple occurrences of org.json.JSONObject on the class path:\r\n"
			+ "\r\n"
			+ "	jar:file:/C:/Users/KevinHuangwl/.m2/repository/org/json/json/20220320/json-20220320.jar!/org/json/JSONObject.class\r\n"
			+ "	jar:file:/C:/Users/KevinHuangwl/.m2/repository/com/vaadin/external/google/android-json/0.0.20131108.vaadin1/android-json-0.0.20131108.vaadin1.jar!/org/json/JSONObject.class\r\n"
			+ "\r\n"
			+ "You may wish to exclude one of them to ensure predictable runtime behavior\r\n"
			+ "\r\n"
			+ "2023-05-06 07:43:36.839  INFO 26408 --- [main] o.d.n.d.jdbc.MarketDataRepositoryTest    : Starting MarketDataRepositoryTest using Java 17.0.2 on DESKTOP-G99DH41 with PID 26408 (started by KevinHuangwl in D:\\workspace\\northstar\\northstar-main)\r\n"
			+ "2023-05-06 07:43:36.840  INFO 26408 --- [main] o.d.n.d.jdbc.MarketDataRepositoryTest    : The following 1 profile is active: \"dev\"\r\n"
			+ "2023-05-06 07:43:37.342  INFO 26408 --- [main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.\r\n"
			+ "2023-05-06 07:43:37.401  INFO 26408 --- [main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 52 ms. Found 8 JPA repository interfaces.\r\n"
			+ "2023-05-06 07:43:37.502  INFO 26408 --- [main] beddedDataSourceBeanFactoryPostProcessor : Replacing 'dataSource' DataSource bean with embedded version\r\n"
			+ "2023-05-06 07:43:37.783  INFO 26408 --- [main] o.s.j.d.e.EmbeddedDatabaseFactory        : Starting embedded database: url='jdbc:h2:mem:3879abff-42c8-4186-bcfc-9b1d8def723e;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=false', username='sa'\r\n"
			+ "2023-05-06 07:43:38.189  INFO 26408 --- [main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]\r\n"
			+ "2023-05-06 07:43:38.239  INFO 26408 --- [main] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 5.6.14.Final\r\n"
			+ "2023-05-06 07:43:38.384  INFO 26408 --- [main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}\r\n"
			+ "2023-05-06 07:43:38.500  INFO 26408 --- [main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect\r\n"
			+ "2023-05-06 07:43:39.146  INFO 26408 --- [main] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]\r\n"
			+ "2023-05-06 07:43:39.155  INFO 26408 --- [main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'\r\n"
			+ "2023-05-06 07:43:39.903  INFO 26408 --- [main] o.d.n.d.jdbc.MarketDataRepositoryTest    : Started MarketDataRepositoryTest in 3.552 seconds (JVM running for 4.495)\r\n"
			+ "2023-05-06 07:43:39.936  INFO 26408 --- [main] o.s.t.c.transaction.TransactionContext   : Began transaction (1) for test context [DefaultTestContext@352ff4da testClass = MarketDataRepositoryTest, testInstance = org.dromara.northstar.data.jdbc.MarketDataRepositoryTest@797b0699, testMethod = testFindByUnifiedSymbolAndTradingDay@MarketDataRepositoryTest, testException = [null], mergedContextConfiguration = [MergedContextConfiguration@3224a577 testClass = MarketDataRepositoryTest, locations = '{}', classes = '{class org.dromara.northstar.NorthstarApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTestContextBootstrapper=true}', contextCustomizers = set[[ImportsContextCustomizer@2e32ccc5 key = [org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration, org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration, org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration, org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration, org.springframework.boot.autoconfigure.sql.init.SqlInitializationAutoConfiguration, org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration, org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration, org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManagerAutoConfiguration]], org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@1a6d8329, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@71ba6d4e, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.autoconfigure.OverrideAutoConfigurationContextCustomizerFactory$DisableAutoConfigurationContextCustomizer@2e8c1c9b, org.springframework.boot.test.autoconfigure.actuate.metrics.MetricsExportContextCustomizerFactory$DisableMetricExportContextCustomizer@78e4deb0, org.springframework.boot.test.autoconfigure.filter.TypeExcludeFiltersContextCustomizer@351584c0, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@ac34dcb1, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@28261e8e, org.springframework.boot.test.context.SpringBootTestArgs@1, org.springframework.boot.test.context.SpringBootTestWebEnvironment@0], contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.event.ApplicationEventsTestExecutionListener.recordApplicationEvents' -> false]]; transaction manager [org.springframework.orm.jpa.JpaTransactionManager@64ef2719]; rollback [true]\r\n"
			+ "2023-05-06 07:43:40.302  INFO 26408 --- [main] o.s.t.c.transaction.TransactionContext   : Rolled back transaction for test: [DefaultTestContext@352ff4da testClass = MarketDataRepositoryTest, testInstance = org.dromara.northstar.data.jdbc.MarketDataRepositoryTest@797b0699, testMethod = testFindByUnifiedSymbolAndTradingDay@MarketDataRepositoryTest, testException = [null], mergedContextConfiguration = [MergedContextConfiguration@3224a577 testClass = MarketDataRepositoryTest, locations = '{}', classes = '{class org.dromara.northstar.NorthstarApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTestContextBootstrapper=true}', contextCustomizers = set[[ImportsContextCustomizer@2e32ccc5 key = [org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration, org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration, org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration, org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration, org.springframework.boot.autoconfigure.sql.init.SqlInitializationAutoConfiguration, org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration, org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration, org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManagerAutoConfiguration]], org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@1a6d8329, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@71ba6d4e, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.autoconfigure.OverrideAutoConfigurationContextCustomizerFactory$DisableAutoConfigurationContextCustomizer@2e8c1c9b, org.springframework.boot.test.autoconfigure.actuate.metrics.MetricsExportContextCustomizerFactory$DisableMetricExportContextCustomizer@78e4deb0, org.springframework.boot.test.autoconfigure.filter.TypeExcludeFiltersContextCustomizer@351584c0, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@ac34dcb1, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@28261e8e, org.springframework.boot.test.context.SpringBootTestArgs@1, org.springframework.boot.test.context.SpringBootTestWebEnvironment@0], contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.event.ApplicationEventsTestExecutionListener.recordApplicationEvents' -> false]]\r\n"
			+ "2023-05-06 07:43:40.310  INFO 26408 --- [main] o.s.t.c.transaction.TransactionContext   : Began transaction (1) for test context [DefaultTestContext@352ff4da testClass = MarketDataRepositoryTest, testInstance = org.dromara.northstar.data.jdbc.MarketDataRepositoryTest@326dbe25, testMethod = testDeleteByExpiredAtBefore@MarketDataRepositoryTest, testException = [null], mergedContextConfiguration = [MergedContextConfiguration@3224a577 testClass = MarketDataRepositoryTest, locations = '{}', classes = '{class org.dromara.northstar.NorthstarApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTestContextBootstrapper=true}', contextCustomizers = set[[ImportsContextCustomizer@2e32ccc5 key = [org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration, org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration, org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration, org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration, org.springframework.boot.autoconfigure.sql.init.SqlInitializationAutoConfiguration, org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration, org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration, org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManagerAutoConfiguration]], org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@1a6d8329, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@71ba6d4e, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.autoconfigure.OverrideAutoConfigurationContextCustomizerFactory$DisableAutoConfigurationContextCustomizer@2e8c1c9b, org.springframework.boot.test.autoconfigure.actuate.metrics.MetricsExportContextCustomizerFactory$DisableMetricExportContextCustomizer@78e4deb0, org.springframework.boot.test.autoconfigure.filter.TypeExcludeFiltersContextCustomizer@351584c0, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@ac34dcb1, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@28261e8e, org.springframework.boot.test.context.SpringBootTestArgs@1, org.springframework.boot.test.context.SpringBootTestWebEnvironment@0], contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.event.ApplicationEventsTestExecutionListener.recordApplicationEvents' -> false]]; transaction manager [org.springframework.orm.jpa.JpaTransactionManager@64ef2719]; rollback [true]\r\n"
			+ "2023-05-06 07:43:40.333  INFO 26408 --- [main] o.s.t.c.transaction.TransactionContext   : Rolled back transaction for test: [DefaultTestContext@352ff4da testClass = MarketDataRepositoryTest, testInstance = org.dromara.northstar.data.jdbc.MarketDataRepositoryTest@326dbe25, testMethod = testDeleteByExpiredAtBefore@MarketDataRepositoryTest, testException = [null], mergedContextConfiguration = [MergedContextConfiguration@3224a577 testClass = MarketDataRepositoryTest, locations = '{}', classes = '{class org.dromara.northstar.NorthstarApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTestContextBootstrapper=true}', contextCustomizers = set[[ImportsContextCustomizer@2e32ccc5 key = [org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration, org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration, org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration, org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration, org.springframework.boot.autoconfigure.sql.init.SqlInitializationAutoConfiguration, org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration, org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration, org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManagerAutoConfiguration]], org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@1a6d8329, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@71ba6d4e, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.autoconfigure.OverrideAutoConfigurationContextCustomizerFactory$DisableAutoConfigurationContextCustomizer@2e8c1c9b, org.springframework.boot.test.autoconfigure.actuate.metrics.MetricsExportContextCustomizerFactory$DisableMetricExportContextCustomizer@78e4deb0, org.springframework.boot.test.autoconfigure.filter.TypeExcludeFiltersContextCustomizer@351584c0, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@ac34dcb1, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@28261e8e, org.springframework.boot.test.context.SpringBootTestArgs@1, org.springframework.boot.test.context.SpringBootTestWebEnvironment@0], contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.event.ApplicationEventsTestExecutionListener.recordApplicationEvents' -> false]]\r\n"
			+ "";
	
	@Test
	void testHasException() throws IOException {
		Reader reader = new StringReader(demoLogHasException);
		ExceptionLogChecker checker = new ExceptionLogChecker(reader);
		assertThat(checker.getExceptionLog(LocalTime.of(22, 0), LocalTime.of(23, 0))).hasSize(1);
		System.out.println(checker.getExceptionLog(LocalTime.of(22, 0), LocalTime.of(23, 0)));
	}
	
	@Test
	void testNoException() throws IOException {
		Reader reader = new StringReader(demoLogHasNoException);
		ExceptionLogChecker checker = new ExceptionLogChecker(reader);
		assertThat(checker.getExceptionLog(LocalTime.of(7, 0), LocalTime.of(8, 59))).isEmpty();
	}
	
	@Test
	void testExceptionExpired() throws IOException {
		Reader reader = new StringReader(demoLogHasException);
		ExceptionLogChecker checker = new ExceptionLogChecker(reader);
		assertThat(checker.getExceptionLog(LocalTime.of(23, 0), LocalTime.of(23, 59))).isEmpty();
	}

}
